package com.umgsai.thread.thread32;

public class Subtract {
	private String lock;
	public Subtract(String lock) {
		super();
		this.lock = lock;
	}
	
	public void subtract() {
		try {
			synchronized (lock) {
				while (ValueObject.list.size() == 0) {
					System.out.println(Thread.currentThread().getName() +  " begin wait " + System.currentTimeMillis());
					lock.wait();
					System.out.println(Thread.currentThread().getName() +  " end wait " + System.currentTimeMillis());
				}
				ValueObject.list.remove(0);
				System.out.println("list size = " + ValueObject.list.size());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
